home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 March / PCWorld_2007-03_cd.bin / v cisle / httrack / httrack-3.41-2.exe / {app} / src / htsbasenet.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-02-03  |  7.6 KB  |  252 lines

  1. /* ------------------------------------------------------------ */
  2. /*
  3. HTTrack Website Copier, Offline Browser for Windows and Unix
  4. Copyright (C) Xavier Roche and other contributors
  5.  
  6. This program is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  19.  
  20.  
  21. Important notes:
  22.  
  23. - We hereby ask people using this source NOT to use it in purpose of grabbing
  24. emails addresses, or collecting any other private information on persons.
  25. This would disgrace our work, and spoil the many hours we spent on it.
  26.  
  27.  
  28. Please visit our Website: http://www.httrack.com
  29. */
  30.  
  31.  
  32. /* ------------------------------------------------------------ */
  33. /* File: Basic net definitions                                  */
  34. /*       Used in .c and .h files that needs hostent and so      */
  35. /* Author: Xavier Roche                                         */
  36. /* ------------------------------------------------------------ */
  37.  
  38. #ifndef HTS_DEFBASENETH
  39. #define HTS_DEFBASENETH
  40.  
  41. #ifdef _WIN32
  42.  
  43. #if HTS_INET6==0
  44.  #include <winsock2.h>
  45. #else
  46.  
  47. #ifndef _WIN32_WCE
  48. #undef HTS_USESCOPEID
  49. #define WIN32_LEAN_AND_MEAN
  50. #include <winsock2.h>
  51. #include <ws2tcpip.h>
  52. #include <tpipv6.h>
  53. #else
  54.  #include <winsock2.h>
  55.  #include <socket.h>
  56. #endif
  57.  
  58. #endif
  59.  
  60. typedef struct hostent FAR t_hostent;
  61.  
  62. #else
  63. #define HTS_USESCOPEID
  64.  #define INVALID_SOCKET -1
  65.  typedef struct hostent t_hostent;
  66. #endif
  67.  
  68. #if HTS_USEOPENSSL
  69. /*
  70.    OpensSSL crypto routines by Eric Young (eay@cryptsoft.com)
  71.    Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  72.    All rights reserved
  73. */
  74. #ifndef HTS_OPENSSL_H_INCLUDED
  75. #define HTS_OPENSSL_H_INCLUDED
  76.  
  77. /*
  78. #include <openssl/ssl.h>
  79. #include <openssl/crypto.h>
  80. #include <openssl/err.h>
  81. */
  82.  
  83. /* Library internal definictions */
  84. #ifdef HTS_INTERNAL_BYTECODE
  85.  
  86. /* OpenSSL definitions */
  87. #define SSL_shutdown hts_ptrfunc_SSL_shutdown
  88. #define SSL_free hts_ptrfunc_SSL_free
  89. #define SSL_new hts_ptrfunc_SSL_new
  90. #define SSL_clear hts_ptrfunc_SSL_clear
  91. #define SSL_set_fd hts_ptrfunc_SSL_set_fd
  92. #define SSL_set_connect_state hts_ptrfunc_SSL_set_connect_state
  93. #define SSL_connect hts_ptrfunc_SSL_connect
  94. #define SSL_get_error hts_ptrfunc_SSL_get_error
  95. #define SSL_write hts_ptrfunc_SSL_write
  96. #define SSL_read hts_ptrfunc_SSL_read
  97. #define SSL_library_init hts_ptrfunc_SSL_library_init
  98. #define ERR_load_crypto_strings hts_ptrfunc_ERR_load_crypto_strings
  99. #define ERR_load_SSL_strings hts_ptrfunc_ERR_load_SSL_strings
  100. #define SSLv23_client_method hts_ptrfunc_SSLv23_client_method
  101. #define SSL_CTX_new hts_ptrfunc_SSL_CTX_new
  102. #define ERR_error_string hts_ptrfunc_ERR_error_string
  103. #define SSL_load_error_strings hts_ptrfunc_SSL_load_error_strings
  104. #define SSL_CTX_ctrl hts_ptrfunc_SSL_CTX_ctrl
  105.  
  106. #endif
  107.  
  108. /* */
  109. typedef void SSL_CTX;
  110. typedef void* SSL;
  111. typedef void SSL_METHOD;
  112. typedef int (*t_SSL_shutdown)(SSL *ssl);
  113. typedef void (*t_SSL_free)(SSL *ssl);
  114. typedef SSL (*t_SSL_new)(SSL_CTX *ctx);
  115. typedef int (*t_SSL_clear)(SSL *ssl);
  116. typedef int (*t_SSL_set_fd)(SSL *ssl, int fd);
  117. typedef void (*t_SSL_set_connect_state)(SSL *ssl);
  118. typedef int (*t_SSL_connect)(SSL *ssl);
  119. typedef int (*t_SSL_get_error)(SSL *ssl, int ret);
  120. typedef int (*t_SSL_write)(SSL *ssl, const void *buf, int num);
  121. typedef int (*t_SSL_read)(SSL *ssl, void *buf, int num);
  122. typedef int (*t_SSL_library_init)(void);
  123. typedef void (*t_ERR_load_crypto_strings)(void);
  124. typedef void (*t_ERR_load_SSL_strings)(void);
  125. typedef SSL_METHOD * (*t_SSLv23_client_method)(void);
  126. typedef SSL_CTX * (*t_SSL_CTX_new)(SSL_METHOD *method);
  127. typedef char * (*t_ERR_error_string)(unsigned long e, char *buf);
  128. typedef void (*t_SSL_load_error_strings)(void);
  129. typedef long (*t_SSL_CTX_ctrl)(SSL_CTX *ctx, int cmd, long larg, char *parg);
  130.  
  131. /* Library internal definictions */
  132. #ifdef HTS_INTERNAL_BYTECODE
  133.  
  134. extern int SSL_is_available;
  135. extern t_SSL_shutdown SSL_shutdown;
  136. extern t_SSL_free SSL_free;
  137. extern t_SSL_new SSL_new;
  138. extern t_SSL_clear SSL_clear;
  139. extern t_SSL_set_fd SSL_set_fd;
  140. extern t_SSL_set_connect_state SSL_set_connect_state;
  141. extern t_SSL_connect SSL_connect;
  142. extern t_SSL_get_error SSL_get_error;
  143. extern t_SSL_write SSL_write;
  144. extern t_SSL_read SSL_read;
  145. extern t_SSL_library_init SSL_library_init;
  146. extern t_ERR_load_crypto_strings ERR_load_crypto_strings;
  147. extern t_ERR_load_SSL_strings ERR_load_SSL_strings;
  148. extern t_SSLv23_client_method SSLv23_client_method;
  149. extern t_SSL_CTX_new SSL_CTX_new;
  150. extern t_ERR_error_string ERR_error_string;
  151. extern t_SSL_load_error_strings SSL_load_error_strings;
  152. extern t_SSL_CTX_ctrl SSL_CTX_ctrl;
  153.  
  154. #endif
  155.  
  156. /*
  157. From /usr/include/openssl/ssl.h
  158. */
  159. #define SSL_ERROR_NONE                  0
  160. #define SSL_ERROR_SSL                   1
  161. #define SSL_ERROR_WANT_READ             2
  162. #define SSL_ERROR_WANT_WRITE            3
  163. #define SSL_ERROR_WANT_X509_LOOKUP      4
  164. #define SSL_ERROR_SYSCALL               5 /* look at error stack/return value/errno */
  165. #define SSL_ERROR_ZERO_RETURN           6
  166. #define SSL_ERROR_WANT_CONNECT          7
  167. #define SSL_OP_ALL                                      0x000FFFFFL
  168. #define SSL_CTRL_OPTIONS                        32
  169. #define SSL_CTX_set_options(ctx,op) \
  170.         SSL_CTX_ctrl(ctx,SSL_CTRL_OPTIONS,op,NULL)
  171.  
  172. //#include <openssl/bio.h>
  173. /* OpenSSL structure */
  174. extern SSL_CTX *openssl_ctx;
  175.  
  176. #endif
  177. #endif
  178.  
  179. /** RFC2616 status-codes ('statuscode' member of htsblk) **/
  180. typedef enum HTTPStatusCode {
  181.   HTTP_CONTINUE = 100,
  182.   HTTP_SWITCHING_PROTOCOLS = 101,
  183.   HTTP_OK = 200,
  184.   HTTP_CREATED = 201,
  185.   HTTP_ACCEPTED = 202,
  186.   HTTP_NON_AUTHORITATIVE_INFORMATION = 203,
  187.   HTTP_NO_CONTENT = 204,
  188.   HTTP_RESET_CONTENT = 205,
  189.   HTTP_PARTIAL_CONTENT = 206,
  190.   HTTP_MULTIPLE_CHOICES = 300,
  191.   HTTP_MOVED_PERMANENTLY = 301,
  192.   HTTP_FOUND = 302,
  193.   HTTP_SEE_OTHER = 303,
  194.   HTTP_NOT_MODIFIED = 304,
  195.   HTTP_USE_PROXY = 305,
  196.   HTTP_TEMPORARY_REDIRECT = 307,
  197.   HTTP_BAD_REQUEST = 400,
  198.   HTTP_UNAUTHORIZED = 401,
  199.   HTTP_PAYMENT_REQUIRED = 402,
  200.   HTTP_FORBIDDEN = 403,
  201.   HTTP_NOT_FOUND = 404,
  202.   HTTP_METHOD_NOT_ALLOWED = 405,
  203.   HTTP_NOT_ACCEPTABLE = 406,
  204.   HTTP_PROXY_AUTHENTICATION_REQUIRED = 407,
  205.   HTTP_REQUEST_TIME_OUT = 408,
  206.   HTTP_CONFLICT = 409,
  207.   HTTP_GONE = 410,
  208.   HTTP_LENGTH_REQUIRED = 411,
  209.   HTTP_PRECONDITION_FAILED = 412,
  210.   HTTP_REQUEST_ENTITY_TOO_LARGE = 413,
  211.   HTTP_REQUEST_URI_TOO_LARGE = 414,
  212.   HTTP_UNSUPPORTED_MEDIA_TYPE = 415,
  213.   HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = 416,
  214.   HTTP_EXPECTATION_FAILED = 417,
  215.   HTTP_INTERNAL_SERVER_ERROR = 500,
  216.   HTTP_NOT_IMPLEMENTED = 501,
  217.   HTTP_BAD_GATEWAY = 502,
  218.   HTTP_SERVICE_UNAVAILABLE = 503,
  219.   HTTP_GATEWAY_TIME_OUT = 504,
  220.   HTTP_HTTP_VERSION_NOT_SUPPORTED = 505
  221. } HTTPStatusCode;
  222.  
  223. /** Internal HTTrack status-codes ('statuscode' member of htsblk) **/
  224. typedef enum BackStatusCode {
  225.   STATUSCODE_INVALID = -1,
  226.   STATUSCODE_TIMEOUT = -2,
  227.   STATUSCODE_SLOW = -3,
  228.   STATUSCODE_CONNERROR = -4,
  229.   STATUSCODE_NON_FATAL = -5,
  230.   STATUSCODE_SSL_HANDSHAKE = -6,
  231.   STATUSCODE_TOO_BIG = -7,
  232.   STATUSCODE_TEST_OK = -10
  233. } BackStatusCode;
  234.  
  235. /** HTTrack status ('status' member of of 'lien_back') **/
  236. typedef enum HTTrackStatus {
  237.   STATUS_ALIVE = -103,
  238.   STATUS_FREE = -1,
  239.   STATUS_READY = 0,
  240.   STATUS_TRANSFER = 1,
  241.   STATUS_CHUNK_CR = 97,
  242.   STATUS_CHUNK_WAIT = 98,
  243.   STATUS_WAIT_HEADERS = 99,
  244.   STATUS_CONNECTING = 100,
  245.   STATUS_WAIT_DNS = 101,
  246.   STATUS_SSL_WAIT_HANDSHAKE = 102,
  247.   STATUS_FTP_TRANSFER = 1000,
  248.   STATUS_FTP_READY = 1001
  249. } HTTrackStatus;
  250.  
  251. #endif
  252.